<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link href="__STATIC__/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <!--<link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">-->
    <!--<link href="/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">-->
    <!--<link href="/static/admin/css/animate.min.css" rel="stylesheet">-->
    <!--<link href="/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">-->
    <!--<link href="/static/admin/css/plugins/chosen/chosen.css" rel="stylesheet">-->
    <!--<link href="/static/admin/css/plugins/switchery/switchery.css" rel="stylesheet">-->
    <!--<link href="/static/admin/css/style.min.css?v=4.1.0" rel="stylesheet">-->
    <!--<link href="/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">-->
    <script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/static/admin/js/layer/layer.js"></script>
    <!--<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>-->
    <!--<script src="/static/admin/js/content.min.js?v=1.0.0"></script>-->
    <!--<script src="/static/admin/js/plugins/chosen/chosen.jquery.js"></script>-->
    <!--<script src="/static/admin/js/plugins/iCheck/icheck.min.js"></script>-->
    <!--<script src="/static/admin/js/plugins/layer/laydate/laydate.js"></script>-->
    <!--<script src="/static/admin/js/plugins/switchery/switchery.js"></script>&lt;!&ndash;IOS开关样式&ndash;&gt;-->
    <!--<script src="/static/admin/js/jquery.form.js"></script>-->
    <!--<script src="/static/admin/js/layer/layer.js"></script>-->
    <!--<script src="/static/admin/js/laypage/laypage.js"></script>-->
    <!--<script src="/static/admin/js/laytpl/laytpl.js"></script>-->
    <!--<script src="/static/admin/js/lunhui.js"></script>-->
    <style>
        .gray-bg{font-family: "Microsoft Yahei"}
        .text{width:100%;height:45px;border:1px #ccc solid;border-radius: 5px;}
        .text1{width:100%;height:45px;border:1px #ccc solid;border-radius: 5px;text-align:center;}
        .p1{font-size:16px;height:18px;color:#000;margin-top:10px;}
        .s1{font-size:16px;color:red;}
        .p2{font-size:18px;height:47px;color:#000; margin:0;}
        .p3{font-size:13px;height:15px;line-hegiht:15px;color:#ccc;padding-left: 3px;}
        .button{font-size:18px;color:#000;width:100%;height:40px;line-height:40px;text-align: center;border-radius: 5px; margin: 0 auto;border:1px #576890 solid;margin-top:50px;}
    </style>

</head>
<body class="gray-bg">
<div class="wrapper wrapper-content bg">
    <form class="form-horizontal m-t" name="add" id="add" method="post" action="save_pwd1">
    <div class="row" >
        <div class="col-sm-12" >
            <p class="p1"><span class="s1">*</span>角色</p>
            <p class="p2">
                <select class="text1" id="role" name="role" onchange="change()">
                    <option value="1">学生</option>
                    <option value="2">家长</option>
                    <option value="3">教师</option>
                    <option value="4">社会人士</option>
                </select>
            </p>
            <p  class="p3">请选择角色</p>
        </div>

        <div class="col-sm-12" >
            <p class="p1"><span class="s1">*</span><span id="xjh">学籍号</span></p>
            <p class="p2"><input class="text" type="text" name="username"  id="username" value=""></p>
        </div>

        <div class="col-sm-12" >
            <p class="p1"><span class="s1">*</span><span id="xm">学生姓名</span></p>
            <p class="p2"><input class="text" type="text" name="name" id="name" value=""></p>
        </div>

        <div class="col-sm-12" id="sj" style="display:block;" >
            <p class="p1"><span class="s1">*</span><span >家长手机</span></p>
            <p class="p2"><input class="text" type="text" name="mobile" id="mobile" value=""></p>
        </div>



        <div class="col-sm-12" >
            <a href="javascript:;" onclick="reg();"><div class="button">确认</div></a>
        </div>

        </div>

    </div>
</div>

    <script type="text/javascript">
        function change(){
           var cc = document.getElementById('role').value;
            if(cc==1){
                document.getElementById('sj').style.display='block';
                document.getElementById('xm').innerHTML='学生姓名';
                document.getElementById('xjh').innerHTML='学籍号';
            }
            if(cc==2){
                document.getElementById('sj').style.display='none';
                document.getElementById('xm').innerHTML='学生姓名';
                document.getElementById('xjh').innerHTML='家长手机';
            }

            if(cc==3){
                document.getElementById('sj').style.display='none';
                document.getElementById('xm').innerHTML='教师姓名';
                document.getElementById('xjh').innerHTML='教师手机';
            }
            if(cc==4){

                document.getElementById('sj').style.display='none';
                document.getElementById('xm').innerHTML='姓名';
                document.getElementById('xjh').innerHTML='帐号';
            }
        }



        function reg(){

            var role =  document.getElementById('role').value;
            var username =  document.getElementById('username').value;
            var mobile =  document.getElementById('mobile').value;
            var name =  document.getElementById('name').value;

            if( '' == username||name==''){
                layer.msg('请填写完整信息', {icon: 5}, function(index){
                    layer.close(index);
                });
                return false;
            }

            if(role==1){
                if(''==mobile){
                    layer.msg('请填写完整信息', {icon: 5}, function(index){
                        layer.close(index);
                    });
                    return false;
                }
            }

            console.log(role+'|'+username+'|'+mobile+'|'+name);



            $.post('{:url("reg")}',
                    {role:role,username:username,mobile:mobile,name:name},
                    function(data){
                        if(data.code==1){
                            document.getElementById("add").submit();
                        }else{
                            layer.msg(data.msg,{icon:5,time:1500,shade: 0.1,});
                            return false;
                        }
                    });
            return false;
        }
    </script>




</body>
</html>